<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>server-sent event</title>
    <link href="//cdn.bootcss.com/normalize/4.2.0/normalize.min.css" rel="stylesheet">
</head>

<body>
    <div id="result">
    </div>
    <script type="text/javascript">
    var source = new EventSource("/receive")
    source.onmessage = function(event) {
        document.getElementById("result").innerHTML += event.data + "<br />";
    }
    source.addEventListener('ping', function(e) {
        result.innerHTML += `${e.type}:${e.data}<br/>`
    })
    </script>
</body>

</html>
